package cn.itcast.bos.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.domain.security.Menu;
import cn.itcast.bos.system.dao.MenuDao;
import cn.itcast.bos.system.service.MenuService;

@Service
@Transactional
public class MenuServiceImpl implements MenuService{

	@Autowired
	private MenuDao menuDao;
	@Override
	public List<Menu> show() {
		// TODO Auto-generated method stub
		return menuDao.findAll();
	}
	@Override
	public void add(Menu t) {
		// TODO Auto-generated method stub
		if(t!=null){
			if(t.getParentMenu()!=null){
				Menu one = menuDao.getOne(t.getParentMenu().getId());
				t.setParentMenu(one);
			}
			menuDao.save(t);
		}
	}
	@Override
	public List<Menu> showMenus(Integer id) {
		// TODO Auto-generated method stub
		return menuDao.showMenusByUserId(id);
	}

}
